<template>
    <div class="success-bg">
        <div class="success">
            <div class="title">
                <span></span>
                <span>申购</span>
                <span @click="close">
                    <img src="../../assets/images/daxin/close.png" alt />
                </span>
            </div>
            <div v-if="show" class="success-content">
                <ul class="list">
                    <li>
                        <span>MATIC 项目</span>
                    </li>
                    <li>
                        <span>中签号码：</span>
                        <span>{{list.actualSignNumber}}</span>
                    </li>
                    <li>
                        <span>未中签号码：</span>
                        <span>{{list.unsignNumber}}</span>
                    </li>
                    <li>
                        中签号码：
                        <span
                            v-show="v.status==1?true:false"
                            v-for="(v,i) in list.listUserPurchaseNumber"
                            :key="i"
                        >{{v.purchaseNumber}}</span>
                    </li>
                    <li>
                        未中签号码：
                        <span
                            v-show="v.status==0?true:false"
                            v-for="(v,i) in list.listUserPurchaseNumber"
                            :key="i"
                        >{{v.purchaseNumber}}</span>
                    </li>
                    <li>
                        <span>申请价格：</span>
                        <span>{{list.unitPrice}} {{list.virtualWalletName}}</span>
                    </li>
                    <li>
                        <span>成交数量：</span>
                        <span>{{list.transactionNumber}} token</span>
                    </li>
                    <li>
                        <span>成交总额：</span>
                        <span>{{list.actualTransactionAccount}} {{list.virtualWalletName}}</span>
                    </li>
                    <li>
                        <span>中签时间：</span>
                        <span>{{list.createTime}}</span>
                    </li>
                </ul>
                <div class="btns">查看订单详情</div>
            </div>
            <div v-else class="fail">
                <img src="../../assets/images/daxin/chahua.png" alt />
                <p>很遗憾，您未中签！</p>
            </div>
        </div>
    </div>
</template>
<script>
import { signNumberPopUp, popUpType } from "../../api/api";
import {mapState} from 'vuex'
import qs from "qs";
export default {
    data() {
        return {
            show: true,
            orLogin: window.sessionStorage.getItem("user"),
            list: [],
            lists: []
        };
    },
    created() {
        this.getMsg();
    },
    computed:{
        ...mapState(['user'])
    },
    methods: {
        close() {
            if (this.lists.length != "") {
                var params = [];
                this.lists.forEach(item => {
                    params.push(item.openSignRecordId);
                });
                popUpType(
                    qs.stringify({
                        openSignRecordId: JSON.stringify(params)
                    })
                ).then(res => {
                    console.log(res.data.data);
                });
            }
            this.$emit("buyColse", false);
        },
        getMsg() {
            var params = {
                userName: this.user.userName
            };
            signNumberPopUp(params).then(res => {
                console.log(res.data, 444);
                if (res.data.code == 200) {
                    if (res.data.data[0].actualSignNumber == 0) {
                        this.show = false;
                    } else {
                        this.list = res.data.data[0];
                        this.lists = res.data.data;
                    }
                }
            });
        }
    }
};
</script>
<style lang="less" scoped>
.title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: bold;
}
.success-bg {
    position: fixed;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 99;
    .success {
        width: 400px;
        margin: 200px auto 0;
        background-color: #fff;
        border-radius: 4px;
        padding: 15px 20px;
        box-sizing: border-box;
        .title {
            display: flex;
            justify-content: space-between;
            align-items: center;
            font-weight: bold;
        }
        .list {
            font-size: 12px;
            li {
                margin-bottom: 30px;
                span:first-child {
                    color: #bac5cb;
                }
            }
            li:first-child {
                span {
                    font-weight: bold;
                    color: #2d2f56;
                }
            }
            li:nth-child(4),
            li:nth-child(5) {
                color: #bac5cb;
                display: flex;
                justify-content: flex-start;
                flex-wrap: wrap;
                span {
                    padding: 2px 10px;
                    border: 1px solid #c7ffed;
                    border-radius: 10px;
                    background-color: #f3fffb;
                    margin: 0 10px 10px 0;
                    color: #4cdfb0;
                }
            }
            li:nth-child(5) {
                span {
                    border: 1px solid #ffd3dc;
                    background-color: #fff5f7;
                    color: #eb375d;
                }
            }
        }
        .btns {
            width: 60%;
            margin: 20px auto;
            height: 35px;
            border: 1px solid #6881ff;
            border-radius: 20px;
            color: #6881ff;
            text-align: center;
            line-height: 35px;
        }
        .fail {
            img {
                display: block;
                width: 250px;
                margin: 100px auto 50px;
            }
            p {
                color: #2d2f56;
                font-size: 14px;
                font-weight: bold;
                text-align: center;
                margin-bottom: 100px;
            }
        }
    }
}
</style>